#include <stdio.h>

#include <linphone/messener.h>
#include "linphonecore.h"

void ShowInterfaceFunc(LinphoneCore *lc){
}

void NotifyPresenceReceivedFunc(LinphoneCore *lc, LinphoneFriend * fid){
}

void NewUnknownSubscriberFunc(LinphoneCore *lc, LinphoneFriend *lf, const char *url){
}

void AuthInfoRequestedFunc(LinphoneCore *lc, const char *realm, const char *username){
}

void DisplayStatusFunc(LinphoneCore *lc, const char *message){
}

void DisplayMessageFunc(LinphoneCore *lc, const char *message){
}

void DisplayMessageWarnFunc(LinphoneCore *lc, const char *message){
}

void DisplayUrlFunc(LinphoneCore *lc, const char *message, const char *url){
}

void DisplayQuestionFunc(LinphoneCore *lc, const char *message){
}

void GeneralStateChangeFunc(LinphoneCore *lc, LinphoneGeneralState *gstate){
}

void BuddyInfoUpdatedFunc(LinphoneCore *lc, LinphoneFriend *lf){
}

void NotifyReceivedFunc(LinphoneCore *lc, const char *from, const char *msg){
}

LinphoneCoreVTable vtable;

int main(){
	int i;

	vtable.show = ShowInterfaceFunc;
	vtable.notify_presence_recv = NotifyPresenceReceivedFunc;
	vtable.new_unknown_subscriber = NewUnknownSubscriberFunc;
	vtable.auth_info_requested = AuthInfoRequestedFunc;
	vtable.display_status = DisplayStatusFunc;
	vtable.display_message = DisplayMessageFunc;
	vtable.display_warning = DisplayMessageWarnFunc;
	vtable.display_url = DisplayUrlFunc;
	vtable.display_question = DisplayQuestionFunc;
	vtable.general_state = GeneralStateChangeFunc;
	vtable.buddy_info_updated = BuddyInfoUpdatedFunc;
	vtable.notify_recv = NotifyReceivedFunc;

	printf("Messenger is startup......\n");

	if(messenger_create(&vtable) == 0){
		printf("Messenger started!\n");

		printf("Logining......\n");
		if(messener_login("gaotao", "gaotao","123456", NULL,"SecWay.org") == 0 ){
			
			printf("Login Success!\n");

			for(i = 0;i < 20;i++){
				messener_iterator();
			}

			messenger_logout();
			printf("Logout\n");
		}else{
			printf("Login failed!\n");
		}

		messenger_destory();
	}else{
		printf("Start up failed!\n");
	}
}